#include "thread_task.h"
#include "opencv2/opencv.hpp"
#include "iostream"
using namespace std;
using namespace cv;
#define BUFF_SIZE 1
Mat img[BUFF_SIZE];

volatile unsigned int product_index;
volatile unsigned int process_index;
thread_task::thread_task()
{
    cout <<"Open the thread of ImageDate" << endl;
}

void thread_task::image_product()
{
    cout << "image product begin" << endl;
    VideoCapture cap(0);
    while(1)
    {
        while(product_index - process_index >= BUFF_SIZE);
        cap >> img[product_index % BUFF_SIZE];
        ++product_index;
//        imshow("iamge", img[0]);

    }
}

void thread_task::image_process()
{
    cout << "image process begin" << endl;
    Mat image;
    while(1)
    {
        while(product_index - process_index == 0);
        img[process_index % BUFF_SIZE].copyTo(image);
        ++process_index;
        imshow("iamge", image);
        waitKey(1);
    }
}
